package _17_剑指Offer;

public class _57_剑指Offer和为s的两个数字 {

    public static void main(String[] args) {

        short a = 1;
        short b = 2;
    }

    public int[] twoSum(int[] nums, int target) {
        int left = 0;
        int right = nums.length - 1;

        while (left < right) {
            int total = nums[left] + nums[right];
            if (total < target) {
                right--;
            } else if (total > target) {
                left++;
            } else {
                return new int[]{nums[left], nums[right]};
            }
        }
        return new int[0];
    }

}
